import 'package:naira_card/public.dart';

class HomeActions extends StatelessWidget {
  const HomeActions({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          padding: const EdgeInsets.symmetric(horizontal: 16),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              // 卖卡按钮
              Expanded(
                flex: 1,
                child: _actionBtn(
                  title: 'Sell Cards',
                  backgroundColor: const Color.fromARGB(255, 41, 80, 252),
                  textColor: Colors.white,
                  icon: const Icon(
                    Icons.card_giftcard,
                    size: 42,
                    color: Colors.white,
                  ),
                  onTap: () {
                    RouterHelper.navigator.pushNamed(Routers.sellGiftCard);
                  },
                ),
              ),
              const SizedBox(width: 12),
              // 提现按钮
              Expanded(
                flex: 1,
                child: _actionBtn(
                  title: 'Withdraw',
                  backgroundColor: const Color.fromARGB(255, 6, 134, 146),
                  textColor: Colors.white,
                  icon: const Icon(
                    Icons.account_balance_wallet_outlined,
                    size: 42,
                    color: Colors.white,
                  ),
                  onTap: () {
                    RouterHelper.navigator.pushNamed(Routers.withdraw);
                  },
                ),
              ),
            ],
          ),
        ),
        const SizedBox(height: 12),
        _moreActions(),
      ],
    );
  }

  /// 操作按钮组件
  Widget _actionBtn({
    required String title,
    required Widget icon,
    required VoidCallback onTap,
    required Color backgroundColor,
    required Color textColor,
  }) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        height: 160,
        padding: const EdgeInsets.symmetric(horizontal: 24),
        decoration: BoxDecoration(
          color: backgroundColor,
          borderRadius: BorderRadius.circular(12),
          boxShadow: [
            BoxShadow(
              color: backgroundColor.withValues(alpha: .3),
              spreadRadius: 1,
              blurRadius: 4,
              offset: const Offset(0, 1),
            ),
          ],
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            icon,
            const SizedBox(height: 12),
            Text(
              title,
              style: TextStyle(
                color: textColor,
                fontSize: 18,
                fontWeight: FontWeight.w600,
              ),
              textAlign: TextAlign.center,
            ),
          ],
        ),
      ),
    );
  }

  Widget _moreActions() {
    return Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisAlignment: MainAxisAlignment.spaceAround,
      children: [
        // 更多操作按钮
        BrnIconButton(
          name: 'PIN',
          iconWidth: 48,
          iconHeight: 48,
          direction: Direction.bottom,
          iconWidget: const Icon(
            Icons.lock,
            size: 48,
            color: Color.fromARGB(255, 91, 91, 91),
          ),
          style: TextStyle(
            color: Color.fromARGB(255, 25, 25, 25),
            fontSize: 18,
          ),
          onTap: () {
            // 更多操作按钮点击事件
          },
        ),
        BrnIconButton(
          name: 'Bank Cards',
          direction: Direction.bottom,
          iconWidth: 48,
          iconHeight: 48,
          iconWidget: const Icon(
            Icons.credit_card,
            color: Color.fromARGB(255, 91, 91, 91),
          ),
          style: TextStyle(
            color: Color.fromARGB(255, 25, 25, 25),
            fontSize: 18,
          ),
          onTap: () {
            // 更多操作按钮点击事件
          },
        ),
      ],
    );
  }
}
